home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / GMS / GMSDev / Includes / dpkernel / dpkernel.i < prev   
Encoding:
Text File  |  1998-05-07  |  11.8 KB  |  393 lines

  1.     IFND DPKERNEL_I
  2. DPKERNEL_I  SET  1
  3.  
  4. **
  5. **  $VER: dpkernel.i V1.0
  6. **
  7. **  General include file for programs using the DPKernel.
  8. **
  9. **  (C) Copyright 1996-1998 DreamWorld Productions.
  10. **      All Rights Reserved.
  11. **
  12. **
  13.  
  14.     IFND    LIBRARIES_DPKERNEL_LIB_I
  15.     include    'modules/dpkernel_lib.i'
  16.     include    'modules/screens.i'
  17.     include    'modules/blitter.i'
  18.     include    'modules/sound.i'
  19.     ENDC
  20.  
  21.     IFND    SYSTEM_TYPES_I
  22.     include 'system/types.i'
  23.     ENDC
  24.  
  25.     IFND    SYSTEM_REGISTER_I
  26.     include    'system/register.i'
  27.     ENDC
  28.  
  29. ****************************************************************************
  30.  
  31. DPKVersion  =  1             ;Version for these includes.
  32. DPKRevision =  0             ;Revision for these includes.
  33.  
  34. SKIPENTRY   =  0             ;Used to skip to the next entry.
  35. ENDLIST     =  -1            ;Used to terminate a list.
  36. LISTEND     =  -1            ;Synonym for ENDLIST.
  37. TAGEND      =  0             ;Used to terminate a tag list.
  38. DEFAULT     =  0
  39.  
  40. TBYTE       =  0             ;Flags used for constructing tag lists.
  41. TLONG       =  (1<<31)
  42. TWORD       =  (1<<30)
  43. TAPTR       =  (1<<29)|TLONG
  44. TSTEPIN     =  (1<<28)
  45. TSTEPOUT    =  (1<<27)
  46. TTRIGGER    =  (1<<26)
  47.  
  48.   IFND    TAG_IGNORE
  49. TAG_IGNORE  =  1
  50. TAG_MORE    =  2
  51. TAG_SKIP    =  3
  52.   ENDC
  53.  
  54. GET_NOTRACK = $00010000             ;Disables tracking on an object.
  55. GET_PUBLIC  = $00020000             ;If the object is to be passed to other tasks/processes.
  56. GET_SHARE   = $00040000|GET_PUBLIC  ;If the object is to be openly shared with foreign tasks.
  57.  
  58. ****************************************************************************
  59. * Function synonyms.
  60.  
  61. _LVODisplay =    _LVOShow
  62. _LVOVisible =    _LVOShow
  63. _LVOInvisible =    _LVOHide
  64.  
  65. ****************************************************************************
  66. * Header used in all objects.
  67.  
  68.     STRUCTURE    Head,0
  69.     WORD    HEAD_ID       ;Object Identifier, eg ID_PICTURE
  70.     WORD    HEAD_Version  ;Version of this object.
  71.     APTR    HEAD_Class    ;Pointer to relevant system object.
  72.     APTR    HEAD_Stats    ;Private.
  73.     LABEL    HEAD_SIZEOF
  74.  
  75.     STRUCTURE    Stats,0             ;This structure is completely private.
  76.     LONG    STATS_Key           ;Resource key.
  77.     APTR    STATS_ChildPrivate  ;Available for child objects.
  78.     LONG    STATS_Flags         ;General flags.
  79.     APTR    STATS_Exclusive     ;What task owns the Exclusive.
  80.     WORD    STATS_LockCount     ;A running count of active locks.
  81.     WORD    STATS_not00         ;
  82.     LONG    STATS_MemFlags      ;Recommended memory allocation flags.
  83.  
  84. ST_SHARED      = $00000001          ;The object is being openly shared.
  85. ST_EXCLUSIVE   = $00000002          ;If object is exclusive to a process.
  86. ST_PUBLIC      = $00000004          ;If GET_PUBLIC was set on Get().
  87. ST_NOTRACKING  = $00000008          ;Do not track resources on this object.
  88. ST_INITIALISED = $00000010          ;This is set by Init().
  89.  
  90. ****************************************************************************
  91. * RawData object.
  92.  
  93. VER_RAWDATA  = 1
  94. TAGS_RAWDATA = ((ID_SPCTAGS<<16)|ID_RAWDATA)
  95.  
  96.    STRUCTURE    RD,HEAD_SIZEOF   ;Standard structure header.
  97.     LONG    RD_Size          ;Size of the data in bytes.
  98.     APTR    RD_Data          ;Pointer to the data.
  99.     BYTE    RD_AFlags        ;Private.
  100.     BYTE    RD_Pad           ;Private.
  101.     LABEL    RD_SIZEOF
  102.  
  103. ****************************************************************************
  104. * List object.
  105.  
  106. VER_ITEMLIST  = 1
  107. TAGS_ITEMLIST = ((ID_SPCTAGS<<16)|ID_ITEMLIST)
  108.  
  109.    STRUCTURE    LST,HEAD_SIZEOF  ;Standard structure header.
  110.     LONG    LST_Array        ;Pointer to the list's array.
  111.     APTR    LST_MaxSize      ;Maximum amount of objects that we can hold.
  112.  
  113. ****************************************************************************
  114. * This macro will allow you to run a DPK program directly (ie no StartDPK),
  115. * and still retain compatibility on other platforms.  It will also set up
  116. * the self-destruct mechanism so that hitting left-amiga and delete will
  117. * destroy your task and leave the system 100% intact with all resources.
  118. *
  119. * Usage: STARTDPK
  120.  
  121.    STRUCTURE    dp1,0
  122.     LONG    DPK_ID    ;ID Header.
  123.     WORD    DPK_Version    ;Version number of this program table.
  124.     WORD    DPK_DPKType    ;Type of jump table from DPK.
  125.     LONG    DPK_Start    ;Start of program.
  126.     APTR    DPK_Name    ;Name of the program.
  127.     APTR    DPK_Author    ;Who wrote the program.
  128.     APTR    DPK_Date    ;Date of compilation.
  129.     APTR    DPK_Copyright    ;Copyright details.
  130.     APTR    DPK_Short    ;Short description of program.
  131.     WORD    DPK_MinVersion    ;Minimum required DPKernel version.
  132.     WORD    DPK_MinRevision    ;Minimum required DPKernel revision.
  133.  
  134. STARTDPK MACRO
  135.     bra.s    StartAmigaDOS    ;Jump if running from AmigaDOS.
  136.  
  137.     dc.l    "PRGM"    ;ID Header.
  138.     dc.w    1    ;Version number of this program table.
  139.     dc.w    JMP_LVO    ;Type of jump table from DPK.
  140.     dc.l    StartDPKernel    ;Start of program.
  141.     dc.l    ProgName    ;Name of the program.
  142.     dc.l    ProgAuthor    ;Who wrote the program.
  143.     dc.l    ProgDate    ;Date of compilation.
  144.     dc.l    ProgCopyright    ;Copyright details.
  145.     dc.l    ProgShort    ;Short description of program.
  146.     dc.w    DPKVersion    ;Minimum required DPKernel version.
  147.     dc.w    DPKRevision    ;Minimum required DPKernel revision.
  148.  
  149. StartAmigaDOS:
  150.     MOVEM.L    D0-D7/A0-A6,-(SP)    ;SP = Save all registers.
  151. .Check    move.l    ($4).w,a6
  152.     sub.l    a1,a1
  153.     jsr    -294(a6)    ;>> = FindTask
  154.     move.l    d0,a4
  155.     tst.l    172(a4)    ;a4 = pr_CLI
  156.     bne.s    .DOS
  157.  
  158. .WBench    lea    92(a4),a0    ;a0 = pr_MsgPort
  159.     jsr    -384(a6)    ;>> = WaitPort()
  160.  
  161.     lea    92(a4),a0    ;a0 = pr_MsgPort
  162.     jsr    -372(a6)    ;>> = GetMsg()
  163.     move.l    d0,ReturnMsg    ;ma = Store message.
  164.  
  165. .DOS    move.l    ($4).w,a6    ;a6 = ExecBase
  166.     lea    DPKName(pc),a1    ;a1 = Library name.
  167.     moveq    #DPKVersion,d0    ;d0 = Version of these includes.
  168.     jsr    -552(a6)    ;>> = OpenLibrary()
  169.     lea    DPKBase(pc),a4
  170.     move.l    d0,(a4)    ;ma = Save base.
  171.     beq    ProgEnd    ;>> = Error, exit.
  172.     move.w    #1,DOS    ;ma = Started from DOS.
  173.  
  174.     move.l    d0,a6    ;a6 = DPKBase.
  175.     lea    ProgExit(pc),a0    ;a0 = Pointer to SelfDestruct() cleanup.
  176.     move.l    a7,a1    ;a1 = Stack pointer.
  177.     CALL    InitDestruct    ;>> = Initialise the call.
  178.     bra.s    Launch
  179.  
  180. StartDPKernel:
  181.     MOVEM.L    D0-D7/A0-A6,-(SP)    ;SP = Save all registers.
  182.     cmp.w    #ID_TASK,(a0)
  183.     bne    ProgEnd
  184.     lea    DPKBase(pc),a4
  185.     move.l    GT_DPKBase(a0),(a4)
  186.     lea    GVBase(pc),a4
  187.     move.l    GT_DPKBase(a0),(a4)
  188.  
  189. Launch:    move.l    DPKBase(pc),a6
  190.     moveq    #MOD_SCREENS,d0
  191.     sub.l    a0,a0
  192.     CALL    OpenModule
  193.     lea    SCRModule(pc),a4
  194.     move.l    d0,(a4)
  195.     beq.s    ProgExit
  196.     move.l    d0,a5
  197.     lea    SCRBase(pc),a4
  198.     move.l    MOD_ModBase(a5),(a4)
  199.  
  200.     moveq    #MOD_BLITTER,d0
  201.     sub.l    a0,a0
  202.     CALL    OpenModule
  203.     lea    BLTModule(pc),a4
  204.     move.l    d0,(a4)
  205.     beq.s    ProgExit
  206.     move.l    d0,a5
  207.     lea    BLTBase(pc),a4
  208.     move.l    MOD_ModBase(a5),(a4)
  209.  
  210.     moveq    #MOD_SOUND,d0
  211.     sub.l    a0,a0
  212.     CALL    OpenModule
  213.     lea    SNDModule(pc),a4
  214.     move.l    d0,(a4)
  215.     beq.s    ProgExit
  216.     move.l    d0,a5
  217.     lea    SNDBase(pc),a4
  218.     move.l    MOD_ModBase(a5),(a4)
  219.  
  220.     bsr    Start\@    ;>> = Start the program.
  221.     tst.l    d0    ;d0 = Check for error.
  222.     beq.s    ProgExit    ;>> = No errors, exit.
  223.     move.l    DPKBase(pc),a6
  224.     CALL    ErrCode    ;>> = Send the error code.
  225.  
  226. ProgExit:
  227.     move.l    DPKBase(pc),a6    ;a6 = DPKBase
  228.     move.l    SCRModule(pc),a0
  229.     CALL    Free
  230.     move.l    BLTModule(pc),a0
  231.     CALL    Free
  232.     move.l    SNDModule(pc),a0
  233.     CALL    Free
  234.  
  235.     move.w    DOS(pc),d0
  236.     beq.s    ProgEnd    ;>> = We started from the StartDPK CLI.
  237.     CALL    CloseDPK    ;>> = Close the kernel.
  238.  
  239.     move.l    ReturnMsg(pc),d0
  240.     beq.s    ProgEnd
  241.     move.l    ($4).w,a6
  242.     jsr    -378(a6)
  243.  
  244. ProgEnd    MOVEM.L    (SP)+,D0-D7/A0-A6    ;SP = Return registers.
  245.     moveq    #ERR_OK,d0    ;d0 = No errors.
  246.     rts
  247.  
  248. DOS:        dc.w  0
  249. SNDBase:    dc.l  0
  250. BLTBase:    dc.l  0
  251. SCRBase:    dc.l  0
  252. SNDModule:    dc.l  0
  253. BLTModule:    dc.l  0
  254. SCRModule:    dc.l  0
  255. ReturnMsg:    dc.l  0
  256. DPKBase:    dc.l  0    ;DPKBase.
  257. GVBase:        dc.l  0     ;Global variable base.
  258. Args:        dc.l  0    ;Pointer to argument string.
  259.  
  260. DPKName:    dc.b  "GMS:libs/dpkernel.library",0
  261.         even
  262. Start\@
  263.     ENDM
  264.  
  265. ******************************************************************************
  266. * This macro provides an easy way of sending a message to IceBreaker.
  267. * The DPKBase must be in register a6.
  268. *
  269. * Example:
  270. *
  271. *    MESSAGE    "Hello World."
  272.  
  273. MESSAGE    MACRO
  274.     MOVEM.L    A5/D7,-(SP)
  275.     moveq    #DBG_Message,d7
  276.     lea    .text\@(pc),a5
  277.     CALL    DebugMessage
  278.     bra.s    .cont\@
  279. .text\@    dc.b    \1,0
  280.     even
  281. .cont\@    MOVEM.L    (SP)+,A5/D7
  282.     ENDM
  283.  
  284. *****************************************************************************
  285. * Universal errorcodes returned by certain functions.  These are further
  286. * explained in the documentation.
  287.  
  288.  STRUCTURE Errors,0
  289.   BYTE  ERR_OK          ;Function went OK.
  290.   BYTE  ERR_NOMEM       ;Not enough memory available.
  291.   BYTE  ERR_NOPTR       ;A required address pointer is not present.
  292.   BYTE  ERR_INUSE       ;Previous allocations have not been freed.
  293.   BYTE  ERR_STRUCT      ;Structure version not supported/not found.
  294.   BYTE  ERR_FAILED      ;General/Miscellaneous failure.
  295.   BYTE  ERR_FILE        ;General file error, eg file not found, disk full etc.
  296.   BYTE  ERR_BADDATA     ;There is an error in the given data.
  297.   BYTE  ERR_SEARCH      ;An internal search was performed and it failed.
  298.   BYTE  ERR_SCRTYPE     ;Screen Type not recognised.
  299.   BYTE  ERR_MODULE      ;Trouble with initialising/using a system module.
  300.   BYTE  ERR_RASTCOMMAND ;Invalid raster command detected.
  301.   BYTE  ERR_RASTERLIST  ;Complete rasterlist failure.
  302.   BYTE  ERR_NORASTER    ;Expected rasterlist is missing from GS_Rasterlist.
  303.   BYTE  ERR_DISKFULL    ;Disk full error.
  304.   BYTE  ERR_FILEMISSING ;File not found.
  305.   BYTE  ERR_WRONGVER    ;Wrong version or version not supported.
  306.   BYTE  ERR_MONITOR     ;Monitor driver not found or cannot be used.
  307.   BYTE  ERR_UNPACK      ;Problem with unpacking of data.
  308.   BYTE  ERR_ARGS        ;Invalid arguments passed to function.
  309.   BYTE  ERR_NODATA      ;No data is available for use.
  310.   BYTE  ERR_READ        ;Error reading data from file.
  311.   BYTE  ERR_WRITE       ;Error writing data to file.
  312.   BYTE  ERR_LOCK        ;Could not obtain lock on object.
  313.   BYTE  ERR_EXAMINE     ;Could not examine the directory or file.
  314.   BYTE  ERR_LOSTCLASS   ;This object has lost its class reference.
  315.   BYTE  ERR_NOACTION    ;This object does not support the required action.
  316.   BYTE  ERR_NOSUPPORT   ;Object does not support the given data.
  317.   BYTE  ERR_MEMORY      ;General memory error.
  318.   BYTE    ERR_TIMEOUT     ;Function timed-out before successful completion.
  319.   BYTE  ERR_NOSTATS     ;This object has lost its stats structure.
  320.   LABEL ERR_END         ;Private code (used by IceBreaker).
  321.  
  322. ERR_SUCCESS   = ERR_OK       ;Synonym for ERR_OK.
  323. ERR_DATA      = ERR_BADDATA  ;Synonym for ERR_BADDATA.
  324. ERR_LOSTSTATS = ERR_NOSTATS  ;Synonym for ERR_NOSTATS.
  325. ERR_NOCLASS   = ERR_LOSTCLASS
  326.  
  327. *****************************************************************************
  328. * Memory types used by AllocMemBlock().  This is almost identical to the
  329. * exec definition but CHIP is renamed to VIDEO (displayable memory) and
  330. * there is an addition of BLIT and SOUND specific memory.  CLEARed memory is
  331. * redundant (all GMS memory is cleared on allocation), REVERSE and NO_EXPUNGE
  332. * are also no longer needed (NB: GMS uses exec's reverse flag to reduce
  333. * fragmentation).
  334.  
  335. MEM_DATA      = $00000000   ;Default.
  336. MEM_PUBLIC    = $00000001   ;Memory can be shared between tasks.
  337. MEM_VIDEO     = $00000002   ;Suitable for the video display and blitting.
  338. MEM_BLIT      = $00000004   ;For blitting only.
  339. MEM_SOUND     = $00000008   ;Sound/Audio memory for playback of sounds.
  340. MEM_CODE      = $00000010   ;For executing code and storing data.
  341. MEM_UNTRACKED = $80000000   ;Do not track the memory.
  342.  
  343. MPUBLIC       = MEM_PUBLIC  ;Synonym.
  344.  
  345. MEMB_PUBLIC    = 0          ;Public access memory.
  346. MEMB_VIDEO     = 1          ;Displayable memory, blitter compatible.
  347. MEMB_BLIT      = 2          ;Blitter memory.
  348. MEMB_SOUND     = 3          ;Sound memory.
  349. MEMB_CODE      = 4          ;Code and data memory.
  350. MEMB_UNTRACKED = 31         ;Do not track the memory.
  351.  
  352.     IFND    SYSTEM_MODULES_I
  353.     include    'system/modules.i'
  354.     ENDC
  355.  
  356.     IFND    GRAPHICS_BLITTER_I
  357.     include    'graphics/blitter.i'
  358.     ENDC
  359.  
  360.     IFND    GRAPHICS_SCREENS_I
  361.     include    'graphics/screens.i'
  362.     ENDC
  363.  
  364.     IFND    GRAPHICS_PICTURES_I
  365.     include 'graphics/pictures.i'
  366.     ENDC
  367.  
  368.     IFND    SYSTEM_MISC_I
  369.     include 'system/misc.i'
  370.     ENDC
  371.  
  372.     IFND    SYSTEM_TASKS_I
  373.     include 'system/tasks.i'
  374.     ENDC
  375.  
  376.     IFND    SOUND_SOUND_I
  377.     include 'sound/sound.i'
  378.     ENDC
  379.  
  380.     IFND    INPUT_JOYPORTS_I
  381.     include 'input/joyports.i'
  382.     ENDC
  383.  
  384.     IFND    INPUT_KEYBOARD_I
  385.     include 'input/keyboard.i'
  386.     ENDC
  387.  
  388.     IFND    FILES_FILES_I
  389.     include 'files/files.i'
  390.     ENDC
  391.  
  392.   ENDC    ;DPKERNEL_I
  393.